package com.kgc.springboot.aviation.service.zzy.Impl;

import com.kgc.springboot.aviation.mapper.BranchMapper;
import com.kgc.springboot.aviation.pojo.Branch;
import com.kgc.springboot.aviation.pojo.BranchExample;
import com.kgc.springboot.aviation.service.zzy.BranchService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BranchServiceImpl implements BranchService {
    @Resource
    BranchMapper branchMapper;
    @Override
    public int add(Branch branch) {
        return branchMapper.insertSelective(branch);
    }

    @Override
    public int upDate(Branch branch) {
        return branchMapper.updateByPrimaryKeySelective(branch);
    }

    @Override
    public Branch upGetAll(Integer id) {
        BranchExample example=new BranchExample();
        if (id!=null && id>0){
            example.createCriteria().andIdEqualTo(id);
            List<Branch> branches = branchMapper.selectByExample(example);
            if (branches!=null&&branches.size()>0){
                return branches.get(0);
            }
        }
        return null;
    }
}
